<template>
  <div>
    <van-nav-bar left-arrow>
        <template #left>
            <van-icon name="arrow-left" @click="$router.back()" />
        </template>
    </van-nav-bar>
    <h2>添加紧急联系人</h2>
    <ul>
        <li>设置后仅在使用<span class="i">110报警</span>或紧急情况下，会主动通知紧急联系人</li>
        <li>您可选择不同紧急联系人<span class="i">开启或关闭</span>自动行程分享</li>
        <li>目前仅支持号码归属地为中国大陆的手机号码</li>
        <li>添加或修改紧急联系人后请及时告知对方</li>
    </ul>
    <van-contact-list
    v-model="chosenContactId"
    :list="list"
    default-tag-text="默认"
    @add="onAdd"
    @edit="onEdit"
    @select="onSelect"
    />
  </div>
</template>

<script>
import { Toast } from 'vant';
export default {
  data() {
    return {
      chosenContactId: '1',
      list: [
        {
          id: '1',
          name: '张三',
          tel: '13000000000',
          isDefault: true,
        },
        {
          id: '2',
          name: '李四',
          tel: '1310000000',
        },
      ],
    };
  },
  methods: {
    onAdd() {
      Toast('新增');
    },
    onEdit(contact) {
      Toast('编辑' + contact.id);
    },
    onSelect(contact) {
      Toast('选择' + contact.id);
    },
  },
}
</script>

<style lang="scss" scoped>
h2{
    padding: 20px 20px 0;
}
ul{
    padding: 20px 10px 10px 25px;
    color: darkgrey;
    font-size: 14px;
}
li{
    padding: 5px;
    list-style-type: disc;
    margin: 5px
}
.i{
    color: orangered;
}
</style>